home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 2004 April / SGI IRIX 6.5 Applications 2004 April.iso / dist / impr_base.idb / usr / sbin / mkscsipr.z / mkscsipr
Text File  |  1998-05-04  |  18KB  |  716 lines

  1. #! /bin/sh
  2. #Tag 0x00000700
  3. #**************************************************************************
  4. #*
  5. #*           Copyright (c) 1992 Silicon Graphics, Inc.
  6. #*            All Rights Reserved
  7. #*
  8. #*       THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF SGI
  9. #*
  10. #* The copyright notice above does not evidence any actual of intended
  11. #* publication of such source code, and is an unpublished work by Silicon
  12. #* Graphics, Inc. This material contains CONFIDENTIAL INFORMATION that is
  13. #* the property of Silicon Graphics, Inc. Any use, duplication or
  14. #* disclosure not specifically authorized by Silicon Graphics is strictly
  15. #* prohibited.
  16. #*
  17. #* RESTRICTED RIGHTS LEGEND:
  18. #*
  19. #* Use, duplication or disclosure by the Government is subject to
  20. #* restrictions as set forth in subdivision (c)(1)(ii) of the Rights in
  21. #* Technical Data and Computer Software clause at DFARS 52.227-7013,
  22. #* and/or in similar or successor clauses in the FAR, DOD or NASA FAR
  23. #* Supplement. Unpublished - rights reserved under the Copyright Laws of
  24. #* the United States. Contractor is SILICON GRAPHICS, INC., 2011 N.
  25. #* Shoreline Blvd., Mountain View, CA 94039-7311
  26. #**************************************************************************
  27. #*
  28. #* File: mkscsipr
  29. #*
  30. #* $Revision: 1.21 $
  31. #*
  32. #* Description: A script to install a System V printer with a SCSI interface.
  33. #*    The script is interactive. The SCSI printer to be installed should
  34. #*    have been powered on before the system was powered on. The script
  35. #*    will permit installation of a SCSI printer that was not on at
  36. #*    system power-on but a warning will be issued.
  37. #*
  38. #*    Usage: mkscsipr
  39. #*
  40. #*    Selection of all installation parameters such as printer name will
  41. #*    be done interactively.
  42. #*
  43. #* Updated for print 1.7 (major changes for print 1.7).  This script no
  44. #* longer parses the output of "lputil list".  It now uses
  45. #* /usr/lib/print/modelinfo and /usr/lib/print/modinfofltr to build
  46. #* the menus that the user sees.  This was done because with PPD files
  47. #* (introduced in Impressario 2.2) it is possible to have a large number
  48. #* of supported printers.  The older code for this routine could not handle
  49. #* a large number of printers (it would overflow string variables).
  50. #*
  51. #**************************************************************************
  52.  
  53.  
  54. # Well known directories and programs
  55.  
  56. LPUTIL_DIR=/usr/lib
  57. LPUTIL=$LPUTIL_DIR/lputil
  58.  
  59. AWK_DIR=/usr/bin
  60. AWK=$AWK_DIR/nawk
  61.  
  62. OUT_FILT="/usr/bin/pg -s -p more... -e"
  63.  
  64. DATA_DIR=/usr/lib/print/data
  65. SPOOL_DIR=/var/spool/lp
  66. POD_DIR=$SPOOL_DIR/pod
  67. DUMMYDEV_DIR=$SPOOL_DIR/devices
  68.  
  69. LPSTAT=/usr/bin/lpstat
  70.  
  71. PRINT_DIR=/usr/lib/print
  72. SETDEVPERMS=$PRINT_DIR/setdevperms
  73.  
  74. MODELINFO=/usr/lib/print/modelinfo
  75. MODELINFOFILTER="/usr/lib/print/modinfofltr -l scsi"
  76.  
  77. # Global variables
  78.  
  79. PMODEL_LIST=""
  80. PTYPE_LIST=""
  81. POPT_LIST=""
  82. NUM_MODELS=0
  83. NUM_VENDORSS=0
  84. VENDOR_ID=""
  85.  
  86. PHINV_LIST=""
  87. NUM_HINV=0
  88. NUM_INTR=0
  89.  
  90. PNAME=""
  91. INTR_NAME=""
  92. UNIT_NUM=""
  93. CTRL_NUM=""
  94. TYPE_ID=""
  95. MODEL_NAME=""
  96. TYPE_NAME=""
  97. DRIVER_PATHNAME=""
  98. DUMMY_DEV=""
  99. SCSI_DEV=""
  100.  
  101.  
  102. #
  103. # Checks that we are the super-user and verifies
  104. # that the System V spooling system is present
  105. #
  106. CheckPermSpooler()
  107. {
  108.     cid=`/usr/bin/id | $AWK '{print substr($1,index($1,"("))}'`;
  109.     if [ "$cid" != "(root)" ]; then
  110.     echo "You must be logged in as root to use this program."
  111.     exit 1;
  112.     fi
  113.     if [ ! -r $SPOOL_DIR ]; then
  114.         echo "The System V spooling system is not installed on this system."
  115.         exit 1
  116.     fi
  117. }
  118.  
  119. #
  120. # Creates a list of connected, powered-on SCSI printers
  121. #
  122. CreateSCSIHinv()
  123. {
  124.     PHINV_LIST=`hinv | grep "unit" | $AWK -F\: 'BEGIN { dosep = 0 }
  125.     {
  126.         if ($1 != "" && ((index($1, "Printer") != 0) || (index($1, "Processor") != 0))    ) {
  127.         n = split($2, arr, " ")
  128.         i = 1
  129.         while (i <= n) {
  130.             if (arr[i] == "unit") {
  131.             i++
  132.             unit = arr[i]
  133.             }
  134.             if (arr[i] == "on") {
  135.             i++
  136.             intr = tolower(arr[i])
  137.             }
  138.             if (arr[i] == "controller") {
  139.             i++
  140.             ctrl = arr[i]
  141.             }
  142.             i++
  143.         }
  144.         if (dosep)
  145.             printf("|")
  146.         else
  147.             dosep = 1
  148.         "/bin/ls /var/spool/lp/member" | getline dcont
  149.         if (length(dcont) != 0) {
  150.             gline = sprintf("%s_c%dd%d *", intr, ctrl, unit)
  151.             if (system("cd /var/spool/lp/member; egrep -s "gline) == 0)
  152.             {
  153.                 "cd /var/spool/lp/member; egrep -l "gline|getline pname
  154.                 printf("%d,%d,%s,%s", ctrl, unit, pname, intr)
  155.             } else {
  156.                 printf("%d,%d,*,%s", ctrl, unit, intr)
  157.             }
  158.         } else {
  159.             printf("%d,%d,*,%s", ctrl, unit, intr)
  160.         }
  161.         }
  162.     }'`
  163.  
  164.     NUM_HINV=`echo $PHINV_LIST | $AWK -F\, 'BEGIN { RS = "|"; count = 0 }
  165.     {
  166.         if ($1 != "")
  167.             count++
  168.     }
  169.     END { printf("%d\n", count) }'`
  170.     NUM_INTR=`echo $PHINV_LIST | $AWK -F\, 'BEGIN { RS = "|"; count = 0 }
  171.     {
  172.         if ($1 != "") {
  173.         if (count == 0) {
  174.             iname = $4
  175.             count++
  176.         } else {
  177.             if (iname != $4) {
  178.             iname = $4
  179.             count++
  180.             }
  181.         }
  182.         }
  183.     }
  184.     END { printf("%d\n", count) }'`
  185.     if [ $NUM_INTR -eq 1 ]; then
  186.     INTR_NAME=`echo $PHINV_LIST | $AWK -F\, 'BEGIN { RS = "|" }
  187.         {
  188.         printf("%s\n", $4)
  189.         exit 0
  190.         }'`
  191.     fi
  192. }
  193.  
  194.  
  195. #
  196. # Displays a list of connected, powered-on SCSI printers
  197. #
  198. ShowSCSIHinv()
  199. {
  200.     echo "SCSI Printers Detected on:"
  201.     echo $PHINV_LIST | $AWK -F\, 'BEGIN { RS = "|" }
  202.     {
  203.             if ($4 != "") {
  204.               printf("\tInterface %s:  controller %d, unit %d", $4, $1, $2)
  205.            if ($3 != "*")
  206.                printf(" (installed as \"%s\")", $3)
  207.            printf("\n")
  208.             }
  209.     }' | $OUT_FILT
  210. }
  211.  
  212.  
  213. #
  214. # Search for a (controller, unit) pair from the list of
  215. # connected SCSI printers
  216. #
  217. # Expects $1 to be the interface name, $2 to be controller number
  218. # and $3 to be unit. Returns 0 if found, 1 if not found
  219. #
  220. FindSCSIDev()
  221. {
  222.     echo $PHINV_LIST | egrep -s "$2,$3,.*,$1"
  223.     return $?
  224. }
  225.  
  226.  
  227. #
  228. # Extracts the model file name from a string similar to:
  229. # "laserwriter_model%SCSI%Apple LaserWriter II%FACEUP=0".
  230. # Would return "laserwriter_model".
  231. #
  232. GetModelFileName()
  233. {
  234.     MODEL_NAME=`echo $* | $AWK  -F\%  '{
  235.             printf("%s\n",$1)
  236.         }'`
  237. }
  238.  
  239.  
  240. #
  241. # Extracts the printer type from a string similar to:
  242. # "laserwriter_model%SCSI%Apple LaserWriter II%FACEUP=0"
  243. # Would return "Apple LaserWriter II".
  244. #
  245. GetPrinterType()
  246. {
  247.     TYPE_NAME=`echo $* | $AWK -F\% '{
  248.             printf("%s\n",$3)
  249.         }'`
  250. }
  251.  
  252.  
  253. #
  254. # Extracts the printer model file options from a string similar to:
  255. # "laserwriter_model%SCSI%Apple LaserWriter II%FACEUP=0"
  256. # Would return "FACEUP=0".
  257. #
  258. GetPrinterOptions()
  259. {
  260.     OPTION_STR=`echo $* | $AWK -F\% '{
  261.             printf("%s\n",$4)
  262.         }'`
  263. }
  264.  
  265.  
  266. #
  267. # Extracts the driver pathname from the POD config file
  268. # Model file name is expected as $1
  269. #
  270. GetDriverPathname()
  271. {
  272.     DRIVER_PATHNAME=`$AWK -F\| '/^[ ]*Driver[ ]+Path/ {
  273.         printf("%s", $2)
  274.         exit
  275.     }' $DATA_DIR/${1}.config`
  276. }
  277.  
  278.  
  279. #
  280. # Changes the Port Path entry in the POD config file to
  281. # the value of $1
  282. #
  283. ChangeConfigPort()
  284. {
  285.     pod_name=$POD_DIR/${PNAME}.config
  286.     $AWK -F\| '{
  287.         if ($1 ~ /^[ ]*Port[ ]+Path/) {
  288.             printf("%s| %s\n", $1, scsidev)
  289.         } else {
  290.         printf("%s\n", $0)
  291.         }
  292.     }' scsidev=$1 $pod_name > $pod_name.new
  293.     mv $pod_name.new $pod_name
  294.     chown lp.lp $pod_name
  295.     chmod 0644 $pod_name
  296. }
  297.  
  298.  
  299. #
  300. # Test for pure decimal positive integer input
  301. #
  302. # Expects $1 to be the value to check. Returns 0 if
  303. # OK, 1 if invalid positive integer or if more than one
  304. # argument specified
  305. #
  306. VerifyInt()
  307. {
  308.     if [ $# -eq 0 ]; then
  309.     return 0
  310.     fi
  311.     if [ $# -gt 1 ]; then
  312.     return 1
  313.     fi
  314.     echo $1 | egrep -s '^[0-9]*$'
  315.     return $?
  316. }
  317.  
  318.  
  319. #
  320. # Test for a valid printer name (i.e. 14 chars max, A-Za-z0-9_
  321. # only and no spaces)
  322. #
  323. VerifyPname()
  324. {
  325.     if [ $# -gt 1 ]; then
  326.     return 1
  327.     fi
  328.     echo $1 | egrep -s '^[A-Za-z0-9_]*$'
  329.     if [ $? -eq 1 ]; then
  330.     return 1
  331.     fi
  332.     if [ `echo $1 | $AWK '{ print length($1) }'` -gt 14 ]; then
  333.         return 1
  334.     else
  335.         return 0
  336.     fi
  337. }
  338.  
  339.  
  340. #
  341. # Test for a valid interface name (i.e. no spaces)
  342. #
  343. VerifyIntrName()
  344. {
  345.     if [ $# -gt 1 ]; then
  346.     return 1
  347.     fi
  348.     return 0
  349. }
  350.  
  351.  
  352. ###################################################################
  353. #
  354. # Main program
  355. #
  356.  
  357. #
  358. # Ensure that we are root and that the main System V
  359. # spooling system directory is present
  360. #
  361. CheckPermSpooler
  362.  
  363. #
  364. # Display an intro message
  365. #
  366. echo "SCSI Printer Installation Tool\n"
  367.  
  368. #
  369. # Query user for a name for this printer
  370. #
  371. while [ "$PNAME" = "" ]; do
  372.     echo "Enter new printer name (14 chars max.): \c"
  373.     read PNAME
  374.     VerifyPname $PNAME
  375.     if [ $? -eq 1 ]; then
  376.     echo "Invalid response: Name must be 14 chars max. (A-Za-z0-9_ only)"
  377.     PNAME=""
  378.     fi
  379.     if [ "$PNAME" = "" ]; then
  380.         continue
  381.     fi
  382.     /bin/ls $SPOOL_DIR/member/$PNAME 2> /dev/null 1> /dev/null
  383.     if [ $? -eq 0 ]; then
  384.         echo ""
  385.         echo "WARNING: Printer $PNAME already exists."
  386.         echo '\nChoose a new name (y/n)[y]? \c'
  387.         read yn
  388.         if [ \( "$yn" != "n" \) -a \( "$yn" != "N" \) ]; then
  389.             PNAME=""
  390.         fi
  391.     fi
  392. done
  393. echo " "
  394.  
  395. #
  396. # Look for SCSI printers connected to the system
  397. # and display what we find
  398. #
  399. CreateSCSIHinv
  400. if [ $NUM_HINV -eq 0 ]; then
  401.     echo "WARNING: No SCSI printers appear to be connected to this system."
  402.     echo "         Check that printer power is on and reboot system."
  403.     echo '\nContinue installation (y/n)[n]? \c'
  404.     read yn
  405.     if [ \( "$yn" != "y" \) -a \( "$yn" != "Y" \) ]; then
  406.         exit 1
  407.     fi
  408. else
  409.     ShowSCSIHinv
  410. fi
  411. echo " "
  412.  
  413. #
  414. # Query user for interface, controller and unit numbers
  415. #
  416. while [ "$INTR_NAME" = "" ]; do
  417.     echo "Enter interface name: \c"
  418.     read INTR_NAME
  419.     VerifyIntrName
  420.     if [ $? -eq 1 ]; then
  421.     echo "Invalid response: Interface name must not contain spaces"
  422.     INTR_NAME=""
  423.     fi
  424. done
  425. while [ "$CTRL_NUM" = "" ]; do
  426.     echo "Enter controller number: \c"
  427.     read CTRL_NUM
  428.     VerifyInt $CTRL_NUM
  429.     if [ $? -eq 1 ]; then
  430.     echo "Invalid response: Controller number must be 0 or greater"
  431.     CTRL_NUM=""
  432.     fi
  433. done
  434. while [ "$UNIT_NUM" = "" ]; do
  435.     echo "Enter unit number: \c"
  436.     read UNIT_NUM
  437.     VerifyInt $UNIT_NUM
  438.     if [ $? -eq 1 ]; then
  439.     echo "Invalid response: Unit number must be 0 or greater"
  440.     UNIT_NUM=""
  441.     fi
  442. done
  443. echo " "
  444.  
  445. #
  446. # Determine an interface prefix for the specified interface name.
  447. # Add new hinv/board pairs here.
  448. #
  449. if [ "$INTR_NAME" = "vme-scsi" ]; then
  450.     INTR_PRE="jag"
  451. elif [ "$INTR_NAME" = "xylogics" ]; then
  452.     INTR_PRE="xyl"
  453. else
  454.     INTR_PRE="sc"
  455. fi
  456.  
  457. #
  458. # Verify that the actual SCSI device driver exists
  459. #
  460. SCSI_DEV=/dev/scsi/${INTR_PRE}${CTRL_NUM}d${UNIT_NUM}l0
  461. /bin/ls $SCSI_DEV 2> /dev/null 1> /dev/null
  462. if [ $? -ne 0 ]; then
  463.     echo "WARNING: Device file $SCSI_DEV does not exist."
  464.     echo '\nContinue installation (y/n)[n]? \c'
  465.     read yn
  466.     if [ \( "$yn" != "y" \) -a \( "$yn" != "Y" \) ]; then
  467.         exit 1
  468.     fi
  469. fi
  470.  
  471. #
  472. # Check whether the interface/controller/unit are in the hinv list
  473. #
  474. FindSCSIDev $INTR_NAME $CTRL_NUM $UNIT_NUM
  475. if [ $? -eq 1 ]; then
  476.     echo "WARNING: Interface $INTR_NAME, controller $CTRL_NUM, unit $UNIT_NUM"
  477.     echo "         does not appear to have a printer connected."
  478.     echo "         Check that printer power is on and reboot system."
  479.     echo '\nContinue installation (y/n)[n]? \c'
  480.     read yn
  481.     if [ \( "$yn" != "y" \) -a \( "$yn" != "Y" \) ]; then
  482.         exit 1
  483.     fi
  484. fi
  485.  
  486. #
  487. # Look for supported SCSI printer types and display what we find
  488. #
  489. echo " "
  490. echo "Determining supported SCSI printer types..."
  491. echo " "
  492.  
  493. # The outer loop is because we allow the user to press return onthe
  494. # secoond menu to jump back to the first menu.
  495.  
  496. GOT_VENDOR_ID=""
  497. while [ "$GOT_VENDOR_ID" = "" ]; do
  498.  
  499.    # Get the user choice of vendor.  User sees something like:
  500.    # 1. GENERIC
  501.    # 2. APPLE
  502.    # 3. GENERIC
  503.  
  504.    VENDOR_ID=""
  505.    while [ "$VENDOR_ID" = "" ]; do
  506.       MODELS_LIST=`$MODELINFO | $MODELINFOFILTER`
  507.       NUM_VENDORS=$?  # modinfoftr returns number of menu items
  508.       echo "$MODELS_LIST" | $OUT_FILT
  509.       if [ $NUM_VENDORS -eq  -1 ]; then
  510.           echo "ERROR. $MODELINFOFILTER returns -1.  -1 indicates"
  511.           echo "program called with invalid arguments."
  512.       fi
  513.       if [ $NUM_VENDORS -eq 0 ]; then
  514.          echo "ERROR: No SCSI printers appear to be supported on this system."
  515.          echo "       Check that print software has been installed."
  516.          exit 1
  517.       fi
  518.       echo " "
  519.       echo "Select printer vendor to use: \c"
  520.       read VENDOR_ID
  521.       VerifyInt $VENDOR_ID
  522.       if [ $? -eq 1 ]; then
  523.            echo "Invalid response: must be number between 1 and $NUM_VENDORS"
  524.            VENDOR_ID=""
  525.       fi
  526.       if [ "$VENDOR_ID" = "" ]; then
  527.            continue
  528.       fi
  529.       if [ \( $VENDOR_ID -eq 0 \) -o \( $VENDOR_ID -gt $NUM_VENDORS \) ]; then
  530.            echo "Invalid response: must be between 1 and $NUM_VENDORS"
  531.            VENDOR_ID=""
  532.       fi
  533.    done
  534.  
  535.    GOT_VENDOR_ID="1"  # Force exit from main loop
  536.  
  537.    # Now list the printer drivers supported for the selected vendor:
  538.    # Get user choice for model. User sees something like:
  539.  
  540.    # 1. APPLE LASERWRITER II
  541.    # 2. APPLE LASERWRITER IIF
  542.    # 3. APPLE LASERWRITER IIG
  543.    # 4. APPLE LASERWRITER IINT
  544.    # 5. APPLE LASERWRITER IINTX
  545.    # 6. APPLE LASERWRITER PLUS
  546.  
  547.    TYPE_ID=""
  548.    while [ "$TYPE_ID" = "" ]; do
  549.       $MODELINFO | $MODELINFOFILTER -v$VENDOR_ID | egrep -i "\(POSTSCRIPT\)" 2> /dev/null 1> /dev/nul
  550.       PPD_FOUND=$?
  551.  
  552.       echo " "
  553.       MODELS_LIST=`$MODELINFO | $MODELINFOFILTER -v$VENDOR_ID`
  554.       NUM_MODELS=$?  # modinfoftr returns number of menu items
  555.       echo "$MODELS_LIST" | $OUT_FILT
  556.       if [ $NUM_MODELS -eq  -1 ]; then
  557.           echo "ERROR. $MODELINFOFILTER returns -1.  -1 indicates"
  558.           echo "program called with invalid arguments."
  559.       fi
  560.  
  561.       if [ $NUM_MODELS -eq  0 ]; then
  562.          echo "ERROR: No SCSI printers appear to be supported for this choice."
  563.          echo "       Check that print software has been installed."
  564.          if [ "$NUM_VENDORS" = "1" ]; then 
  565.             exit 1 
  566.          fi
  567.          echo ""
  568.          echo "Press Enter to return to last menu.\c"
  569.          read TYPE_ID
  570.          TYPE_ID=1         # Bogus value to get out of this loop
  571.          GOT_VENDOR_ID=""  # Re-start main loop to go back to last menu
  572.          echo ""
  573.          continue
  574.       fi
  575.  
  576.       if [ "$PPD_FOUND" = "0" ]; then
  577.       echo ""
  578.         echo "NOTE: Printer model names followed by \"(PostScript)\" will only work"
  579.         echo "with printers that have built-in PostScript support.  Some of"
  580.         echo "these printers do not come with built-in PostScript and it must"
  581.         echo "be purchased from the printer vendor as a separate option."
  582.       fi
  583.  
  584.       echo ""
  585.       echo "Select printer model to use (press Enter for last menu): \c"
  586.       read TYPE_ID
  587.       if [ "$TYPE_ID" = "" ]; then
  588.          TYPE_ID=1         # Bogus value to get out of this loop
  589.          GOT_VENDOR_ID=""  # Re-start main loop to go back to last menu
  590.          echo ""
  591.          continue
  592.       fi
  593.       VerifyInt $TYPE_ID
  594.       if [ $? -eq 1 ]; then
  595.            echo "Invalid response: must be number between 1 and $NUM_MODELS"
  596.            TYPE_ID=""
  597.       fi
  598.       if [ \( $TYPE_ID -eq 0 \) -o \( $TYPE_ID -gt $NUM_MODELS \) ]; then
  599.            echo "Invalid response: must be between 1 and $NUM_MODELS"
  600.            TYPE_ID=""
  601.       fi
  602.    done
  603.  
  604. done
  605.  
  606. #
  607. # Inform the user of what comes next
  608. #
  609. echo " "
  610. echo "Installing SCSI printer $PNAME..."
  611. echo " "
  612.  
  613. #
  614. # Get the model info string for the selected printer and pull out
  615. # the parts we need.
  616. #
  617.  
  618. modelstring=`$MODELINFO | $MODELINFOFILTER -v$VENDOR_ID -c$TYPE_ID`
  619. if [ $? -eq  -1 ]; then
  620.     echo "ERROR. $MODELINFOFILTER returns -1.  -1 indicates"
  621.     echo "program called with invalid arguments."
  622. fi
  623.  
  624. GetModelFileName $modelstring
  625. GetPrinterType $modelstring
  626. GetPrinterOptions $modelstring
  627.  
  628. #
  629. # If one does not already exist, create a dummy device file for
  630. # lp to open. The dummy device is just /dev/null (same major and
  631. # minor numbers. We cannot create a link because lputil changes the
  632. # device file permissions and ownership.
  633. #
  634. if [ ! -d $DUMMYDEV_DIR ]; then
  635.     mkdir $DUMMYDEV_DIR
  636.     chmod 755 $DUMMYDEV_DIR
  637.     chown lp.sys $DUMMYDEV_DIR
  638. fi
  639. DUMMY_DEV=$DUMMYDEV_DIR/${INTR_NAME}_c${CTRL_NUM}d${UNIT_NUM}
  640. dev_info=`/bin/ls -l /dev/null`
  641. major_dev=`echo $dev_info|$AWK '{print substr($5,$5,index($5,",")-1)}'`
  642. minor_dev=`echo $dev_info|$AWK '{print $6}'`
  643. rm -f $DUMMY_DEV
  644. /etc/mknod $DUMMY_DEV c $major_dev $minor_dev
  645. chmod 664 $DUMMY_DEV
  646. chown lp.sys $DUMMY_DEV
  647.  
  648. #
  649. # Install the printer. We use awk to execute the lputil command
  650. # because we want the OPTION_STR strings handled properly (i.e.
  651. # with the proper quoting).
  652. #
  653. echo $LPUTIL add $DUMMY_DEV $MODEL_NAME $PNAME \
  654.     NAME=\'\"$TYPE_NAME\"\' $OPTION_STR | $AWK '{
  655.         rv = system($0)
  656.         exit rv
  657.     }'
  658.  
  659. #
  660. # Now edit the config file to contain the proper
  661. # SCSI device file. The printer driver obtains the
  662. # device file from the config file rather than from
  663. # the spooling system
  664. #
  665. ChangeConfigPort $SCSI_DEV
  666.  
  667. #
  668. # Change permissions on the actual SCSI device file.
  669. # This way SCSI drivers do not have to be setuid
  670. # root programs. lputil will change the owner and
  671. # permissions back to root when the printer is removed.
  672. #
  673.  
  674. #
  675. # For 6.4 this needs to add an entry to /etc/ioperms so permissions
  676. # are restored when a reboot is done. See ioconfig man page.
  677. #
  678. chown lp.sys $SCSI_DEV
  679. chmod 600 $SCSI_DEV
  680. $SETDEVPERMS -a "$SCSI_DEV 0600 lp sys"
  681.  
  682. #
  683. # With the name of the model file we can obtain the
  684. # pathname of the driver by looking at the POD config file
  685. #
  686. GetDriverPathname $MODEL_NAME
  687.  
  688. #
  689. # Run the driver in update status mode to ensure that config
  690. # and status files reflect installed printer options
  691. #
  692. if [ "$DRIVER_PATHNAME" = "" ]; then
  693.     echo "WARNING: A driver entry could not be found in the POD config file."
  694.     echo "         Check Driver Path entry in $POD_DIR/${PNAME}.config"
  695. elif [ ! -x $DRIVER_PATHNAME ]; then
  696.     echo "WARNING: The driver for this printer is not executable."
  697.     echo "         Check permissions and ownership of $DRIVER_PATHNAME"
  698. else
  699.     $DRIVER_PATHNAME -s -e -P $PNAME
  700. fi
  701.  
  702. #
  703. # Inform the user of what has happened
  704. #
  705. echo " "
  706. echo "SCSI Printer $PNAME has been installed"
  707. echo " "
  708. echo "Here is your current printing environment:"
  709. echo " "
  710. $LPSTAT -t | $OUT_FILT
  711.  
  712. #
  713. # Return a successful exit code
  714. #
  715. exit 0
  716.